package com.haredot.entity;

import com.alibaba.fastjson2.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.haredot.validation.Insert;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class Sys implements Serializable {

    @Serial
    private static final long serialVersionUID = -5060518567837888329L;

    private Long id;
    /**
    * 系统名
    */
    @NotEmpty(message = "系统名称不能为空", groups = {Insert.class})
    @Length(max = 100, message = "系统名过长")
    private String sysName;

    /**
    * 系统接口前缀
    */
    @NotEmpty(message = "系统首页地址不能为空", groups = {Insert.class})
    @Pattern(regexp = "^\\/.*$", message = "url格式不正确", groups = {Insert.class})
    private String url;

    @NotEmpty(message = "系统编号不能为空", groups = {Insert.class})
    @Pattern(regexp = "^[a-zA-Z-]+[a-zA-Z]$", message = "系统编号由字母中划线组成", groups = {Insert.class})
    private String remark ;
    /**
    * 系统描述
    */
    private String description;

    /**
    * 系统状态
    */
    @NotNull(message = "系统状态不能为空", groups = {Insert.class})
    private Boolean state;

    /**
    * 录入时间
    */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    /**
    * 修改时间
    */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;

    /**
    * 是否删除
    */
    private Boolean del;
}